/**
 * 
 */
package org.yelongframework.excel.workbook;

import java.util.List;
import java.util.stream.Collectors;

import org.yelongframework.core.print.Printer;
import org.yelongframework.excel.cell.ExcelCell;
import org.yelongframework.excel.row.ExcelRow;
import org.yelongframework.excel.sheet.ExcelSheet;

/**
 * 工具
 * 
 * @since 1.0.0
 */
public final class ExcelWorkbookUtils {

	// ==================================================构造器==================================================

	private ExcelWorkbookUtils() {
	}

	// ==================================================打印==================================================

	/**
	 * 打印数据
	 * 
	 * @param excelWorkbook excel工作薄
	 */
	public static void print(ExcelWorkbook excelWorkbook) {
		print(excelWorkbook, Printer.SYSTEM_OUT_PRINTLN);
	}

	/**
	 * 打印数据
	 * 
	 * @param excelWorkbook excel工作薄
	 * @param printer       打印机
	 */
	public static void print(ExcelWorkbook excelWorkbook, Printer printer) {
		List<ExcelSheet> sheetList = excelWorkbook.getSheetList();
		for (int i = 0; i < sheetList.size(); i++) {
			ExcelSheet excelSheet = sheetList.get(i);
			printer.print("sheet" + i + "(" + excelSheet.getSheetName() + ")");
			List<ExcelRow> rowList = excelSheet.getRowList();
			for (ExcelRow excelRow : rowList) {
				List<ExcelCell> cellList = excelRow.getCellList();
				String info = cellList.stream().map(ExcelCell::getValueString).collect(Collectors.joining("\t"));
				printer.print(info);
			}
		}
	}

}
